package com.xyauto.theme.bean;

import android.os.Parcel;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.xyauto.theme.App;
import com.xyauto.theme.BuildConfig;
import com.xyauto.theme.utils.SelectManager;

import java.util.List;
import java.util.Locale;

/**
 * 界面易主题
 */
public class JMEThemeBean implements IThemeBean {


    private int mIndex;
    private String mPreview;
    private String mWallpaper;

    public JMEThemeBean(int index, String preview, String wallpaper) {
        this.mIndex = index;
        this.mPreview = preview;
        this.mWallpaper = wallpaper;
    }

    public static final Creator<JMEThemeBean> CREATOR = new Creator<JMEThemeBean>() {
        @Override
        public JMEThemeBean createFromParcel(Parcel in) {
            return new JMEThemeBean(in);
        }

        @Override
        public JMEThemeBean[] newArray(int size) {
            return new JMEThemeBean[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    protected JMEThemeBean(Parcel in) {
        mIndex = in.readInt();
        mPreview = in.readString();
        mWallpaper = in.readString();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(mIndex);
        dest.writeString(mPreview);
        dest.writeString(mWallpaper);
    }


    @Override
    public boolean isSelected() {
        return SelectManager.INSTANCE.isSelectTheme(mIndex);
    }

    @NonNull
    @Override
    public String getName() {
        return String.format(Locale.getDefault(), "UI_%02d", (mIndex + 1));
    }

    @NonNull
    @Override
    public String getPreviewImage() {
        return mPreview;
    }


    @Nullable
    @Override
    public String getApkPath() {
        return null;
    }

    @Nullable
    @Override
    public String getUrlPath() {
        return null;
    }

    @Override
    public boolean isExists() {
        return true;
    }

    @NonNull
    @Override
    public String getVersion() {
        return App.Companion.findLauncherVer();
    }


    public int getIndex() {
        return mIndex;
    }

    public String getWallpaper() {
        return mWallpaper;
    }

    @Nullable
    @Override
    public List<String> getPreviewImages() {
        return null;
    }
}
